package stu.aistar.mapper;

import org.apache.ibatis.annotations.*;
import stu.aistar.model.pojo.MovieType;

import java.util.List;

@Mapper
public interface MovieTypeMapper {

    List<MovieType> findMovieTypeByIds(@Param("ids")String[] ids);

    @Select("select *from movietype")
    List<MovieType> findAll();

    @Select("select count(*) from movietype")
    Integer findTotal();

    @Select("select * from movietype where type_name = #{typeName}")
    MovieType findMovieTypeByName(@Param("typeName") String name);

    @Insert("insert into movietype(type_name) values (#{typeName}) ")
    @Options(useGeneratedKeys = true, keyColumn = "id")
    Integer insertMovieType(@Param("typeName") String name);

    @Update("update movietype set type_name = #{typeName} where id =#{id}")
    Integer updateTypeById(MovieType movieType);

    @Delete("delete from movietype where type_name = #{name}")
    Integer deleteTypeByName(@Param("name")String name);
}
